import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsNumber } from "class-validator";

export class CreatePostDto {
  @IsNotEmpty({ message: "文章标题不能为空" })
  @ApiProperty({ description: "文章标题" })
  readonly title: string;

  @IsNotEmpty({ message: '作者不能为空' })
  @ApiProperty({ description: "文章作者" })
  readonly author: string;

  @IsNotEmpty({ message: '内容不能位空' })
  @ApiProperty({ description: "文章内容" })
  readonly content: string;

  @ApiProperty({ description: "文章摘要", required: false})
  readonly summary?: string;

  @ApiProperty({ description: "文章封面" })
  readonly cover_url: string;

  @ApiPropertyOptional({ description: '文章状态' })
  readonly status: string;

  @ApiPropertyOptional({ description: '是否推荐' })
  public is_recommend: number;

  @IsNumber()
  @ApiProperty({ description: '文章分类' })
  readonly category: number;

  @ApiPropertyOptional({ description: '文章标签' })
  readonly tag: string;
}

export class PostInfoDto {
  @IsNotEmpty({ message: "文章标题不能为空" })
  @ApiProperty({ description: "文章标题" })
  public title: string;

  @IsNotEmpty({ message: "作者id不能为空" })
  @ApiProperty({ description: "作者id" })
  public userId: number;

  @IsNotEmpty({ message: '作者不能为空' })
  @ApiProperty({ description: "文章作者" })
  public author: string;

  @IsNotEmpty({ message: '内容不能位空' })
  @ApiProperty({ description: "文章内容" })
  public content: string;

  @ApiProperty({ description: "文章内容html", required: false})
  public contentHtml?: string;

  @ApiProperty({ description: "文章摘要", required: false})
  public summary?: string;

  @ApiProperty({ description: "文章封面" })
  public cover_url: string;

  @ApiPropertyOptional({ description: '文章状态' })
  public status: string;

  @IsNumber()
  @ApiProperty({ description: '文章分类' })
  public category: string;

  @ApiPropertyOptional({ description: '文章标签' })
  public tags: Array<string>;

  @ApiProperty({ description: "点赞数" })
  public like_count: number; // 点赞数

  @ApiProperty({ description: "阅读量" })
  public count: number; // 阅读量

  @ApiPropertyOptional({ description: '是否推荐' })
  public is_recommend: number;
}